package com.example.demo3.controller;


import com.example.demo3.bean.UserAddVo;
import com.example.demo3.util.ResultBuildVo;
import com.example.demo3.util.ResultVo;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
public class BiaoDanController {

    @PostMapping("/user/add")
    public ResultVo add(@RequestBody @Valid UserAddVo useraddvo, BindingResult bindingresult){
        if(bindingresult.hasErrors()){
            return ResultBuildVo.error(bindingresult.getFieldError().getDefaultMessage());
        }

        return ResultBuildVo.success(useraddvo);
    }
}
